import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import {JVxeTypes,JVxeColumn} from '/@/components/jeecg/JVxeTable/types'
import { getWeekMonthQuarterYear } from '/@/utils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '订单单号',
    align:"center",
    dataIndex: 'orderCode'
   },
   {
    title: '门店编号',
    align:"center",
    dataIndex: 'storeCode_dictText'
   },
   {
    title: '收件人',
    align:"center",
    dataIndex: 'receiptName'
   },
   {
    title: '收件人手机号',
    align:"center",
    dataIndex: 'receiptPhone'
   },
   {
    title: '收件地址省市区',
    align:"center",
    dataIndex: 'receiptZone',
   },
   {
    title: '收件详细地址',
    align:"center",
    dataIndex: 'receiptAddress'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
     {
      label: "订单单号",
      field: "orderCode",
      component: 'Input', //TODO 范围查询
      //colProps: {span: 6},
	},
	{
      label: "门店",
      field: "storeCode",
      component: 'JSelectMultiple',
      componentProps:{
          dictCode:"xl_customer_store_info,store_name,store_code"
      },
      //colProps: {span: 6},
 	},
     {
      label: "收件人",
      field: "receiptName",
      component: 'Input', //TODO 范围查询
      //colProps: {span: 6},
	},
     {
      label: "收件人手机号",
      field: "receiptPhone",
      component: 'Input', //TODO 范围查询
      //colProps: {span: 6},
	},
	{
      label: "收件地址省市区",
      field: "receiptZone",
      component: 'JAreaLinkage',
      componentProps: {
        saveCode: 'region',
      },
      //colProps: {span: 6},
 	},
     {
      label: "收件详细地址",
      field: "receiptAddress",
      component: 'Input', //TODO 范围查询
      //colProps: {span: 6},
	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '订单单号',
    field: 'orderCode',
    component: 'Input',
  },
  {
    label: '门店编号',
    field: 'storeCode',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"xl_customer_store_info,store_name,store_code"
     },
  },
  {
    label: '收件人',
    field: 'receiptName',
    component: 'Input',
  },
  {
    label: '收件人手机号',
    field: 'receiptPhone',
    component: 'Input',
  },
  {
    label: '收件地址省市区',
    field: 'receiptZone',
    component: 'JAreaLinkage',
    componentProps: {
      saveCode: 'region',
    },
  },
  {
    label: '收件详细地址',
    field: 'receiptAddress',
    component: 'Input',
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];
//子表单数据
//子表表格配置
export const xlCustomerOrderDetailColumns: JVxeColumn[] = [
    {
      title: '商品ID',
      key: 'productId',
      type: JVxeTypes.popup,
      popupCode:"xl_product_list",
      fieldConfig: [
        { source: 'id', target: 'productName' },
      ],

      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '产品价格',
      key: 'productPrice',
      type: JVxeTypes.inputNumber,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '订单数量',
      key: 'orderQuantity',
      type: JVxeTypes.inputNumber,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '订单金额',
      key: 'orderAmount',
      type: JVxeTypes.inputNumber,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
  ]


// 高级查询数据
export const superQuerySchema = {
  orderCode: {title: '订单单号',order: 0,view: 'text', type: 'string',},
  storeCode: {title: '门店编号',order: 1,view: 'list', type: 'string',dictTable: "xl_customer_store_info", dictCode: 'store_code', dictText: 'store_name',},
  receiptName: {title: '收件人',order: 2,view: 'text', type: 'string',},
  receiptPhone: {title: '收件人手机号',order: 3,view: 'text', type: 'string',},
  receiptZone: {title: '收件地址省市区',order: 4,view: 'pca', type: 'string',},
  receiptAddress: {title: '收件详细地址',order: 5,view: 'text', type: 'string',},
  //子表高级查询
  xlCustomerOrderDetail: {
    title: '订单明细',
    view: 'table',
    fields: {
        productId: {title: '商品ID',order: 0,view: 'popup', type: 'string',code: 'xl_product_list', orgFields: 'id', destFields: 'productId', popupMulti: false,},
        productPrice: {title: '产品价格',order: 1,view: 'number', type: 'number',},
        orderQuantity: {title: '订单数量',order: 2,view: 'number', type: 'number',},
        orderAmount: {title: '订单金额',order: 3,view: 'number', type: 'number',},
    }
  },
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
// 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}